import torch


def getDataloader(opt, dataset):
    dataloader = torch.utils.data.DataLoader(
        dataset,
        batch_size=opt.batch_size,
        shuffle=not opt.serial_batches,
        num_workers=int(opt.num_workers),
        drop_last=opt.phase == 'train',
        pin_memory=True
    )
    return dataloader